import os
import time
from ctypes import cdll

class KeySimulator :
	PRESS_UP = 0
	PRESS_DOWN = 1
	PRESS_LEFT = 2
	PRESS_RIGHT = 3
	PRESS_ENTER = 4
	PRESS_ESC = 5
	PRESS_HOME = 6

	def __init__(self):
		self.lib = cdll.LoadLibrary("./lib/Util_KeyPressSimulator.so")

	def simPress(self, key):
		if key == "UP" :
			self.lib.press(self.PRESS_UP)
		elif key == "DOWN" :
			self.lib.press(self.PRESS_DOWN)
		elif key == "LEFT" :
			self.lib.press(self.PRESS_LEFT)
		elif key == "RIGHT" :
			self.lib.press(self.PRESS_RIGHT)
		elif key == "HOME" :
			self.lib.press(self.PRESS_HOME)
		elif key == "B" :
			self.lib.press(self.PRESS_ESC)
		elif key == "A" :
			self.lib.press(self.PRESS_ENTER)

		print "simulating " + str(key)

if __name__ == "__main__" :
	k = KeySimulator()
	for i in range(10000):
		k.simPress("UP")	
		print "count =" + str(i)
		#time.sleep(.5)
